package http

import (
	"github.com/gin-gonic/gin"
	"shangke-device/app/http/controller"
	"shangke-device/app/http/middleware"
	"shangke-device/app/svcContent"
)

func InitRouter(svc *svcContent.SvcContent) *gin.Engine {
	gin.SetMode(svc.Conf.HttpConf.Mode)
	router := gin.New()
	//router.Use(middleware.GinLogger(svc.Log), middleware.GinRecovery(svc.Log, false))
	router.Use(middleware.GinLogger(svc.Log), gin.Recovery())

	device := controller.NewDevice(svc)
	authorized := router.Group("/", middleware.AuthorizedMiddleware(svc))
	{
		authorized.POST("device/open", device.Open())
	}

	return router
}
